package com.jic.market.enums;

import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/4/13
 * @description: 拼团实例详情支付状态   支付状态：0未支付，1已支付，2已失效
 * @modified By:
 * @version: V1.0
 */
public enum GrouponDetailPaymentStatusEnum {
    //  支付状态：0未支付，1已支付，2已失效
    PAY_NOT(0, "未支付"),
    PAY_HAVE(1, "已支付"),
    LOSE_EFFECT(2, "已失效"),
    ;

    private Integer code;

    private String value;

    GrouponDetailPaymentStatusEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static GrouponDetailPaymentStatusEnum getEnumByCode(Integer code){
        EnumSet<GrouponDetailPaymentStatusEnum> elements = EnumSet.allOf(GrouponDetailPaymentStatusEnum.class);
        for(GrouponDetailPaymentStatusEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static int getCodeByValue(String value) {
        for (GrouponDetailPaymentStatusEnum c : GrouponDetailPaymentStatusEnum.values()) {
            if (c.getValue().equals(value.trim())) {
                return c.code;
            }
        }
        return 0;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
